package com.yinkgh.util;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;
import org.apache.commons.beanutils.converters.SqlTimestampConverter;

/**
 * bean属性值拷贝
 * 处理日期为空的情况
 * @author yinkgh
 *
 */
public class BeanCopyUtil {
	
	static {
		ConvertUtils.register(new DateConverter(null), java.util.Date.class); 
		ConvertUtils.register(new DateConverter(null), java.sql.Date.class); 
		ConvertUtils.register(new SqlTimestampConverter(null), java.sql.Timestamp.class);
	}
	
	public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException {
		BeanUtils.copyProperties(dest, orig);
	}
	
}
